package com.ssh.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ssh.bean.Users;
import com.ssh.dao.UserDAO;

public class UserDAOImpl extends HibernateDaoSupport implements UserDAO {

	@SuppressWarnings("unchecked")
	public List<Users> findAllUsers() {
		String hql = "from Users users order by users.id desc";
		return (List<Users>)this.getHibernateTemplate().find(hql);
	}

	public Users findUsersById(Integer id) {

		Users users = (Users)this.getHibernateTemplate().get(Users.class, id);

		return users;
	}

	public void removeUsers(Users users) {

		this.getHibernateTemplate().delete(users);
	}

	public void saveUsers(Users users) {

		this.getHibernateTemplate().save(users);
	}

	public void updateUsers(Users users) {

		this.getHibernateTemplate().update(users);
	}

}
